使用os3grid做一個基於Web和Ajax的工資表錄入介面

來源:互聯網
上載者:User

1 首先對os3grid做一些小的修改:加入下面代碼

function strlen(str)
{
var len;
var i;
len = 0;
for (i=0;i{
if (str.charCodeAt(i)>255) len+=2; else len++;
}
return len;
}

然後在function grid_cell_txt_edit ( cell )裡面修改以下一行,主要是應付中文

s += ' size="'+ strlen(val) + '" ';

另外,修改一些顏色

 this.cols = { "hover"  : "#d5f1ff",

2 工資表結構

考慮到每一個單位都有不同的帳套,所以按一對多建立帳套表

CREATE TABLE pq_unitgzxm (
   unit_id char(8) NOT NULL DEFAULT '',
   xmbh int NOT NULL DEFAULT 0,
   xmbm varchar(3) NOT NULL PRIMARY KEY,
   xmmc varchar(200) NOT NULL DEFAULT '',
   lx varchar(200)  NOT NULL DEFAULT '',
   jsgs varchar(200)  NOT NULL DEFAULT ''
  )
 
INSERT INTO pq_unitgzxm values ('00000001',1,'F01','員工號','系統值','');
INSERT INTO pq_unitgzxm values ('00000001',2,'F02','姓名','系統值','');
INSERT INTO pq_unitgzxm values ('00000001',3,'F03','單位','系統值','');
INSERT INTO pq_unitgzxm values ('00000001',4,'F04','基本工資','錄入值','');
INSERT INTO pq_unitgzxm values ('00000001',5,'F05','獎金','錄入值','');
INSERT INTO pq_unitgzxm values ('00000001',6,'F06','應發工資','計算值','');
INSERT INTO pq_unitgzxm values ('00000001',7,'F07','個人所得稅','計算值','');
INSERT INTO pq_unitgzxm values ('00000001',8,'F08','應扣工資','計算值','');
INSERT INTO pq_unitgzxm values ('00000001',9,'F09','實發工資','計算值','');

實際工資錄入採用空間冗餘的辦法

CREATE TABLE pq_gzxm (
   gzb_id char(8) NOT NULL DEFAULT '',
   employee_id char(8) NOT NULL DEFAULT '',
   xm varchar(400)  NOT NULL DEFAULT '',
   employeecontract_id char(8) NOT NULL DEFAULT '',
   gzdata1 decimal  NOT NULL DEFAULT '0',
   gzdata2 decimal  NOT NULL DEFAULT '0',
   gzdata3 decimal  NOT NULL DEFAULT '0',
   gzdata4 decimal  NOT NULL DEFAULT '0',
   gzdata5 decimal  NOT NULL DEFAULT '0',
   gzdata6 decimal  NOT NULL DEFAULT '0',
   gzdata7 decimal  NOT NULL DEFAULT '0',
   gzdata8 decimal  NOT NULL DEFAULT '0',
   gzdata9 decimal  NOT NULL DEFAULT '0',
   gzdata10 decimal  NOT NULL DEFAULT '0',
   gzdata11 decimal  NOT NULL DEFAULT '0',
   gzdata12 decimal  NOT NULL DEFAULT '0',
   gzdata13 decimal  NOT NULL DEFAULT '0',
   gzdata14 decimal  NOT NULL DEFAULT '0',
   gzdata15 decimal  NOT NULL DEFAULT '0',
   gzdata16 decimal  NOT NULL DEFAULT '0',
   gzdata17 decimal  NOT NULL DEFAULT '0',
   gzdata18 decimal  NOT NULL DEFAULT '0',
   gzdata19 decimal  NOT NULL DEFAULT '0',
   gzdata20 decimal  NOT NULL DEFAULT '0'
  )   

  
INSERT INTO pq_gzxm (gzb_id,employee_id,xm,employeecontract_id,gzdata1) values ('00000001','00000001','張三','00000001',0);   
INSERT INTO pq_gzxm (gzb_id,employee_id,xm,employeecontract_id,gzdata1) values ('00000001','00000002','李四','00000002',0);   

3  產生表單

function show_form($unit_id = '', $gzyear ='', $gzmonth='',$error = '') {
 global $db, $me, $t,$_POST;

 extract($_POST);
 if ($unit_id && !$error) {
  $rs = $db->Execute("select * from ".TBL_UNITGZXM." where unit_id = '$unit_id'");
  $items = $rs->GetArray();
  $t->assign('items', $items);
  
  //$rs = $db->Execute("select e.employee_id,e.xm,ec.dwmc from ".TBL_EMPLOYEE." e,".TBL_EMPLOYEECONTRACT." ec,".TBL_UNITCONTRACT." uc where e.employee_id=

ec.employee_id and ec.unitcontract_id = uc.unitcontract_id and uc.unit_id ='$unit_id'");
  //$t->assign('employees', $rs->GetArray());
    $gzb_id = '';
    $dwmc = '';

  $gzb = $db->GetRow("select gzb_id,dwmc from ".TBL_GZB." where unit_id = '$unit_id'

and gzyear='2006' and gzmonth='04'");
   
    $gzb_id = $gzb['gzb_id'];
    $dwmc = $gzb['dwmc'];

  $gz_array = array();
  $rs = $db->Execute("select * from ".TBL_GZXM." where gzb_id = '$gzb_id'");
  while (!$rs->EOF) {
   
      $gzdata_array = array();
     
      //gzdata1 從1開始
      for ($i = 1, $count = count($items)-3; $i             array_push($gzdata_array, $rs->fields['gzdata'.$i]);
    }

      $gzline = array($rs->fields['employee_id'],$rs->fields['xm'],$dwmc,$gzdata_array);
      array_push($gz_array, $gzline);
        
     $rs->MoveNext();
    }

 } else {
  $t->assign($_POST);
 }
 
 //print_r($gz_array);
 $t->assign('error', $error);
 $t->assign('gz_array', $gz_array);
 $t->render('salary.html', PAGE_TITLE,'wrap.html',False);
}

表單範本

 

4 http_fetch_sync 函數如下

var global_xmlhttp = getXMLHTTPinstance();

function http_fetch_sync(url,post_data)
{

global_xmlhttp = getXMLHTTPinstance();

 var method = 'GET';
 if ( typeof(post_data) != 'undefined' )
 {
   method = 'POST';
 }

 try
 {
 //global_xmlhttp.open(method, url,true);
 global_xmlhttp.open(method, url,false);
 }
 catch(e)
 {
   alert('message:'+e.message+":url:"+url);
 }
 if ( method == 'POST')
 {
   global_xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
 }

 global_xmlhttp.send(post_data);
 var args = {"responseText":global_xmlhttp.responseText,"responseXML":global_xmlhttp.responseXML,

"request_id":request_id};
 return args;

}

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=668611

相關文章

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。