Ejemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            BillOutDialog billDialog = new BillOutDialog(masterTable.NewRow());
            if (billDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    DataRow row = billDialog.MasterRow;
                    row["STATE"] = "1";
                    row["STATEDESC"] = "����";
                    row["OPERATER"] = UserID;
                    row["USERNAME"] = UserName;
                    row["OPERATEDATE"] = SysDate;

                    DataTable table = billDal.GetMasterIn(row["SCHEDULENO"].ToString());
                    if (table.Rows.Count != 0 && table.Rows[0]["STATE"].ToString() != "4")//����������ҵ
                    {
                        THOKUtil.ShowInfo("��ǰ�����̰���δ��⣬�������������εij��ⵥ��");
                        return;
                    }

                    //row["ORIBILLNO"] = "";
                    //row["STATUS"] = "0";//�ֹ�����
                    //row["STATUSNAME"] = "�ֹ�����";

                    //billDal.AddBill(row, billDialog.DetailTable, "P", row["BILLDATE"].ToString());

                    if (row["BILLNO"].ToString() != "")//���ݴ����ⷢ��ʱ���ɵij��ⵥ�����µij��ⵥ
                    {
                        row["BILLNO"] = billDal.RecoverBill(row["BILLNO"].ToString(), SysDate);
                    }
                    else//�ֹ�����
                    {
                        row["ORIBILLNO"] = "";
                        row["STATUS"] = "0";//�ֹ�����
                        row["STATUSNAME"] = "�ֹ�����";
                        billDal.AddBill(row, billDialog.DetailTable, "P", row["BILLDATE"].ToString());

                    }

                    masterTable.Rows.InsertAt(row, 0);
                    bsMaster.Position = 0;
                }
                catch (Exception exp)
                {
                    THOKUtil.ShowInfo("�������ⵥʧ�ܣ�ԭ��" + exp.Message);
                }
            }
        }
Ejemplo n.º 2
0
 private void btnModify_Click(object sender, EventArgs e)
 {
     if (dgvMaster.CurrentRow != null)
     {
         DataRow masterRow = ((DataRowView)dgvMaster.CurrentRow.DataBoundItem).Row;
         //ֻ���ֹ����ӵij��ⵥ��״̬Ϊ�ѱ���ʱ���ܽ����޸�
         BillOutDialog billDialog = new BillOutDialog(masterRow, detailTable, masterRow["STATUS"].ToString() == "0" && masterRow["STATE"].ToString() == "1");
         if (billDialog.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 detailTable = billDialog.DetailTable;
                 billDal.SaveBill(masterRow, detailTable);
             }
             catch (Exception exp)
             {
                 THOKUtil.ShowInfo("������ⵥʧ�ܣ�ԭ��" + exp.Message);
             }
         }
         else
             detailTable.RejectChanges();
     }
 }