Пример #1
0
        public F_KHMau_Details()
        {
            InitializeComponent();
            Load += (s, e) =>
            {
                this.Width  = Screen.PrimaryScreen.Bounds.Width * 3 / 5;
                this.Height = Screen.PrimaryScreen.Bounds.Height - 30;

                action_EndForm1.Add_Status(false);
                action_EndForm1.Delete_Status(false);
                action_EndForm1.Update_Status(false);
                action_EndForm1.Save_Status(true);
                action_EndForm1.View_Status(true);
                action_EndForm1.Close_Status(false);

                action_EndForm2.Add_Status(true);
                action_EndForm2.Delete_Status(true);
                action_EndForm2.Update_Status(true);
                action_EndForm2.Save_Status(false);
                action_EndForm2.View_Status(false);
                action_EndForm2.Close_Status(false);

                action_EndForm3.Add_Status(false);
                action_EndForm3.Delete_Status(false);
                action_EndForm3.Update_Status(false);
                action_EndForm3.Save_Status(true);
                action_EndForm3.View_Status(false);
                action_EndForm3.Close_Status(true);

                cmbNhanVienHuyMau.ReadOnly = true;
                txtTaiLieuHuy.ReadOnly     = true;
                dteNgayHuyMau.ReadOnly     = true;
                txtSoLuongHuy.ReadOnly     = true;

                this.Location = new System.Drawing.Point(Screen.PrimaryScreen.Bounds.Right - this.Width, 0);

                if (KHMAUOBJ.SoPXN.Substring(0, 3) == "GEN" || KHMAUOBJ.SoPXN.Substring(0, 3) == "HTH" || KHMAUOBJ.SoPXN.Substring(0, 3) == "MDW")
                {
                    //cmbLoaiDV
                    layoutControlItem30.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                    layoutControlItem30.Text       = "Loại động vật";

                    //cmbMauNuoc
                    layoutControlItem29.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    layoutControlItem29.Text       = "Mẫu nước :";

                    layoutControlItem33.Text = "Tuổi :";

                    layoutControlItem35.Text = "Tên mẫu :";
                }
                else if (KHMAUOBJ.SoPXN.Substring(0, 3) == "H2O")
                {
                    //cmbLoaiDV
                    layoutControlItem30.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    layoutControlItem30.Text       = "Loài động vật :";

                    //cmbMauNuoc
                    layoutControlItem29.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                    layoutControlItem29.Text       = "Mẫu nước";

                    layoutControlItem33.Text = "Giờ lấy mẫu :";

                    layoutControlItem35.Text = "Vị trí lấy mẫu :";
                }

                if (isAction == "Edit")
                {
                    layoutControlGroup4.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;

                    txtSoPXN.ReadOnly = true;

                    Set4Controls_Header();
                    Set4Controls_Details();

                    gridControl1.DataSource = this.tbl_KHMau_CTXN_LABTableAdapter.FillBy(this.sYNC_NUTRICIELDataSet.tbl_KHMau_CTXN_LAB, KHMAUOBJ.KHMau);
                }
                else if (isAction == "Add")
                {
                    txtKHMau.Text = this.str_KHMau;
                    Set4Controls_Header();

                    txtKHMau.ReadOnly = false;
                    txtSoPXN.ReadOnly = true;
                    txtID.ReadOnly    = true;
                    layoutControlGroup4.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                }
            };

            gridView1.RowClick += (s, e) =>
            {
                KHMAUCTXNOBJ.ID  = int.Parse(gridView1.GetFocusedRowCellValue("ID").ToString());
                gridViewRowClick = true;
                Set4Object_Details();
            };

            btnCopy.Click += (s, e) =>
            {
                if (this.dxValidationProvider1.Validate() == true)
                {
                    DialogResult dlDel = XtraMessageBox.Show(" Bạn muốn sao chép chỉ tiêu xét nghiệm từ kí hiệu mẫu " + lkeKHMau.SelectedText + " sang kí hiệu mẫu " + txtKHMau.Text, "Xóa thông tin", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dlDel == DialogResult.Yes)
                    {
                        if (gridView1.RowCount > 0)
                        {
                            if (this.dxValidationProvider1.Validate() == true)
                            {
                                Set4Object_Header();
                                Set4Object_Details();
                                BUS1.KHMau_LABBUS_UPDATE(KHMAUOBJ);
                                ///////////////////////////////////////////
                                for (int i = 0; i <= gridView1.RowCount - 1; i++)
                                {
                                    DataRow dr = gridView1.GetDataRow(i);
                                    KHMAUCTXNOBJ.SoLuongXN         = txtSoLuong.Text;                              //txtSoLuongXN.Text;
                                    KHMAUCTXNOBJ.DonGia            = float.Parse(dr["DonGia"].ToString());         //float.Parse(txtDonGia.Text.ToString());
                                    KHMAUCTXNOBJ.VAT               = float.Parse(dr["VAT"].ToString());            //float.Parse(txtVAT.Text.ToString());
                                    KHMAUCTXNOBJ.DonGiaMuaNgoai    = float.Parse(dr["DonGiaMuaNgoai"].ToString()); //float.Parse(txtDonGiaMuaNgoai.Text.ToString());
                                    KHMAUCTXNOBJ.DonGiaSauDiscount = float.Parse(dr["DonGia"].ToString());
                                    //XtraMessageBox.Show("KHMAUCTXNOBJ.DonGiaSauDiscount "+ KHMAUCTXNOBJ.DonGiaSauDiscount.ToString());
                                    //XtraMessageBox.Show("txtSoLuong.Text " + txtSoLuong.Text);
                                    //XtraMessageBox.Show("KHMAUCTXNOBJ.VAT "+ KHMAUCTXNOBJ.VAT.ToString());
                                    if (KHMAUCTXNOBJ.DonGiaSauDiscount != 0)
                                    {
                                        KHMAUCTXNOBJ.ThanhTien = (KHMAUCTXNOBJ.DonGiaSauDiscount * float.Parse(txtSoLuong.Text) * (100 + KHMAUCTXNOBJ.VAT) / 100);//(KHMAUCTXNOBJ.DonGiaSauDiscount * float.Parse(txtSoLuongXN.Text) * (100 + KHMAUCTXNOBJ.VAT) / 100);
                                    }
                                    else
                                    {
                                        KHMAUCTXNOBJ.ThanhTien = 0;
                                    }
                                    KHMAUCTXNOBJ.KHMau    = txtKHMau.Text;                                                        //txtKHMau.Text;
                                    KHMAUCTXNOBJ.KHMau_ID = int.Parse(txtID.Text);                                                //int.Parse(txtID.Text);
                                                                                                                                  //XtraMessageBox.Show("PriceList_Details_LAB_Id" + dr["PriceList_Details_LAB_Id"].ToString());
                                    KHMAUCTXNOBJ.PriceList_Details_LAB_Id = int.Parse(dr["PriceList_Details_LAB_Id"].ToString()); //int.Parse(txtPriceList_Details_LAB_Id.Text);
                                    KHMAUCTXNOBJ.KHMau_ID = KHMAUOBJ.ID;
                                    KHMAUCTXNOBJ.CTXNID   = int.Parse(dr["CTXNID"].ToString());                                   //int.Parse(txtCTXNID.Text.ToString());


                                    BUS2.KHMau_CTXN_LABBUS_INSERT(KHMAUCTXNOBJ);

                                    if (float.Parse(KHMAUCTXNOBJ.SoLuongXN) >= 1)
                                    {
                                        for (int j = 0; j < int.Parse(KHMAUCTXNOBJ.SoLuongXN); j++)
                                        {
                                            //KHMAUCTXNRESULT.KHMau_CTXN_ID = KHMAUCTXNOBJ.ID;
                                            KHMAUCTXNRESULT.KHMau_CTXN_ID = BUS3.MAX_KHMau_CTXN_LABDAO_ID();
                                            KHMAUCTXNRESULT.LineNo        = j;
                                            BUS3.KHMau_CTXN_LABDAO_INSERT(KHMAUCTXNRESULT);
                                        }
                                    }
                                    else
                                    {
                                        KHMAUCTXNRESULT.KHMau_CTXN_ID = BUS3.MAX_KHMau_CTXN_LABDAO_ID();
                                        KHMAUCTXNRESULT.LineNo        = 0;
                                        BUS3.KHMau_CTXN_LABDAO_INSERT(KHMAUCTXNRESULT);
                                    }
                                }
                                XtraMessageBoxArgs args = new XtraMessageBoxArgs();
                                args.AutoCloseOptions.Delay = 2000;
                                args.AutoCloseOptions.ShowTimerOnDefaultButton = true;
                                args.DefaultButtonIndex = 0;
                                args.Caption            = "Sao chép thành công";
                                args.Text    = "Sao chép chỉ tiêu xét nghiệm từ kí hiệu mẫu " + lkeKHMau.SelectedText + " sang kí hiệu mẫu " + txtKHMau.Text;
                                args.Buttons = new DialogResult[] { DialogResult.OK, DialogResult.Cancel };
                                XtraMessageBox.Show(args).ToString();
                                Is_close = true;
                            }
                            else
                            {
                                IList <Control> IControls = this.dxValidationProvider1.GetInvalidControls();
                                foreach (Control ctrl in IControls)
                                {
                                    ctrl.Focus();
                                }
                            }
                        }
                    }

                    else
                    {
                        XtraMessageBoxArgs args = new XtraMessageBoxArgs();
                        args.AutoCloseOptions.Delay = 2000;
                        args.AutoCloseOptions.ShowTimerOnDefaultButton = true;
                        args.DefaultButtonIndex = 0;
                        args.Caption            = "Hủy sao chép ";
                        args.Text    = "Không tiến hành sao chép.";
                        args.Buttons = new DialogResult[] { DialogResult.OK, DialogResult.Cancel };
                        XtraMessageBox.Show(args).ToString();
                    }
                }
                else
                {
                    IList <Control> IControls = this.dxValidationProvider1.GetInvalidControls();
                    foreach (Control ctrl in IControls)
                    {
                        ctrl.Focus();
                    }
                }
                //F_KHMau_Details_Saochep frm = new F_KHMau_Details_Saochep();
                //frm.Show();
            };

            chkHuyMau.CheckedChanged += (s, e) =>
            {
                if (chkHuyMau.CheckState == CheckState.Checked)
                {
                    KHMAUOBJ.TrangThaiKHMau    = false;
                    cmbNhanVienHuyMau.ReadOnly = false;
                    txtTaiLieuHuy.ReadOnly     = false;
                    dteNgayHuyMau.ReadOnly     = false;
                    txtSoLuongHuy.ReadOnly     = false;
                }
                else
                {
                    KHMAUOBJ.TrangThaiKHMau    = true;
                    cmbNhanVienHuyMau.ReadOnly = true;
                    txtTaiLieuHuy.ReadOnly     = true;
                    dteNgayHuyMau.ReadOnly     = true;
                    txtSoLuongHuy.ReadOnly     = true;
                }
            };

            chkLuuMau.CheckedChanged += (s, e) =>
            {
                if (chkLuuMau.CheckState == CheckState.Checked)
                {
                    KHMAUOBJ.TrangThaiKHMau    = true;
                    cmbNhanVienHuyMau.ReadOnly = true;
                    txtTaiLieuHuy.ReadOnly     = true;
                    dteNgayHuyMau.ReadOnly     = true;
                    txtSoLuongHuy.ReadOnly     = true;
                }
                else
                {
                    KHMAUOBJ.TrangThaiKHMau    = false;
                    cmbNhanVienHuyMau.ReadOnly = false;
                    txtTaiLieuHuy.ReadOnly     = false;
                    dteNgayHuyMau.ReadOnly     = false;
                    txtSoLuongHuy.ReadOnly     = false;
                }
            };

            GrdLoaiDongVat.ButtonClick += (s, e) =>
            {
                if (e.Button.Index == 1)
                {
                    //Disable
                    this.Enabled = false;
                    //
                    F_LoaiDV_Details FRM = new F_LoaiDV_Details();
                    FRM.isAction = "Add";
                    //FRM.ngaynhanmau = this.ngaynhanmau;
                    //FRM.KHMAUOBJ = this.KHMAUOBJ;
                    //FRM.KHMAUCTXNOBJ = this.KHMAUCTXNOBJ;
                    FRM.myFinished += this.finished;
                    FRM.Show();
                }
            };

            GrdLoaiMauGui.ButtonClick += (s, e) =>
            {
                if (e.Button.Index == 1)
                {
                    //Disable
                    this.Enabled = false;
                    //
                    F_LoaiMauGoi_Details FRM = new F_LoaiMauGoi_Details();
                    FRM.isAction = "Add";
                    this.Visible = false;
                    //FRM.ngaynhanmau = this.ngaynhanmau;
                    //FRM.KHMAUOBJ = this.KHMAUOBJ;
                    //FRM.KHMAUCTXNOBJ = this.KHMAUCTXNOBJ;
                    FRM.myFinished += this.finished;
                    FRM.Show();
                }
            };

            //Action_EndForm
            action_EndForm1.Add(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Add));
            action_EndForm1.Update(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Update));
            action_EndForm1.Close(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Close));
            action_EndForm1.Save(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Save));
            //Action_EndForm
            action_EndForm2.Add(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Add2));
            action_EndForm2.Update(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Update2));
            action_EndForm2.Close(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Close2));
            action_EndForm2.Save(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Save2));
            action_EndForm2.Delete(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Delete2));
            //Action_EndForm
            action_EndForm3.Add(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Add3));
            action_EndForm3.Update(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Update3));
            action_EndForm3.Close(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Close3));
            action_EndForm3.Save(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Save3));
        }
        public F_KHMau_Details_Saochep()
        {
            InitializeComponent();
            Load += (s, e) =>
            {
                this.Width  = Screen.PrimaryScreen.Bounds.Width * 3 / 5;
                this.Height = Screen.PrimaryScreen.Bounds.Height - 30;

                action_EndForm1.Add_Status(false);
                action_EndForm1.Delete_Status(false);
                action_EndForm1.Update_Status(false);
                action_EndForm1.Save_Status(true);
                action_EndForm1.View_Status(true);
                action_EndForm1.Close_Status(false);

                action_EndForm2.Add_Status(true);
                action_EndForm2.Delete_Status(true);
                action_EndForm2.Update_Status(true);
                action_EndForm2.Save_Status(false);
                action_EndForm2.View_Status(false);
                action_EndForm2.Close_Status(false);

                action_EndForm3.Add_Status(false);
                action_EndForm3.Delete_Status(false);
                action_EndForm3.Update_Status(false);
                action_EndForm3.Save_Status(true);
                action_EndForm3.View_Status(false);
                action_EndForm3.Close_Status(true);

                cmbNhanVienHuyMau.ReadOnly = true;
                txtTaiLieuHuy.ReadOnly     = true;
                dteNgayHuyMau.ReadOnly     = true;
                txtSoLuongHuy.ReadOnly     = true;

                this.Location = new System.Drawing.Point(Screen.PrimaryScreen.Bounds.Right - this.Width, 0);

                if (KHMAUOBJ.SoPXN.Substring(0, 3) == "GEN" || KHMAUOBJ.SoPXN.Substring(0, 3) == "HTH" || KHMAUOBJ.SoPXN.Substring(0, 3) == "MDW")
                {
                    //cmbLoaiDV
                    layoutControlItem30.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                    layoutControlItem30.Text       = "Loại động vật";

                    //cmbMauNuoc
                    layoutControlItem29.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    layoutControlItem29.Text       = "Mẫu nước :";

                    layoutControlItem33.Text = "Tuổi :";

                    layoutControlItem35.Text = "Dãy chuồng :";
                }
                else if (KHMAUOBJ.SoPXN.Substring(0, 3) == "H2O")
                {
                    //cmbLoaiDV
                    layoutControlItem30.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    layoutControlItem30.Text       = "Loài động vật :";

                    //cmbMauNuoc
                    layoutControlItem29.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                    layoutControlItem29.Text       = "Mẫu nước";

                    layoutControlItem33.Text = "Giờ lấy mẫu :";

                    layoutControlItem35.Text = "Vị trí lấy mẫu :";
                }

                if (isAction == "Edit")
                {
                    layoutControlGroup4.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;

                    txtSoPXN.ReadOnly = true;

                    Set4Controls_Header();
                    Set4Controls_Details();

                    gridControl1.DataSource = this.tbl_KHMau_CTXN_LABTableAdapter.FillBy(this.sYNC_NUTRICIELDataSet.tbl_KHMau_CTXN_LAB, KHMAUOBJ.KHMau);
                }
                else if (isAction == "Add")
                {
                    txtKHMau.Text = this.str_KHMau;
                    Set4Controls_Header();

                    txtKHMau.ReadOnly = false;
                    txtSoPXN.ReadOnly = true;
                    txtID.ReadOnly    = true;
                    layoutControlGroup4.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                }
            };

            gridView1.RowClick += (s, e) =>
            {
                KHMAUCTXNOBJ.ID  = int.Parse(gridView1.GetFocusedRowCellValue("ID").ToString());
                gridViewRowClick = true;
                Set4Object_Details();
            };

            chkHuyMau.CheckedChanged += (s, e) =>
            {
                if (chkHuyMau.CheckState == CheckState.Checked)
                {
                    KHMAUOBJ.TrangThaiKHMau    = false;
                    cmbNhanVienHuyMau.ReadOnly = false;
                    txtTaiLieuHuy.ReadOnly     = false;
                    dteNgayHuyMau.ReadOnly     = false;
                    txtSoLuongHuy.ReadOnly     = false;
                }
                else
                {
                    KHMAUOBJ.TrangThaiKHMau    = true;
                    cmbNhanVienHuyMau.ReadOnly = true;
                    txtTaiLieuHuy.ReadOnly     = true;
                    dteNgayHuyMau.ReadOnly     = true;
                    txtSoLuongHuy.ReadOnly     = true;
                }
            };

            chkLuuMau.CheckedChanged += (s, e) =>
            {
                if (chkLuuMau.CheckState == CheckState.Checked)
                {
                    KHMAUOBJ.TrangThaiKHMau    = true;
                    cmbNhanVienHuyMau.ReadOnly = true;
                    txtTaiLieuHuy.ReadOnly     = true;
                    dteNgayHuyMau.ReadOnly     = true;
                    txtSoLuongHuy.ReadOnly     = true;
                }
                else
                {
                    KHMAUOBJ.TrangThaiKHMau    = false;
                    cmbNhanVienHuyMau.ReadOnly = false;
                    txtTaiLieuHuy.ReadOnly     = false;
                    dteNgayHuyMau.ReadOnly     = false;
                    txtSoLuongHuy.ReadOnly     = false;
                }
            };

            GrdLoaiDongVat.ButtonClick += (s, e) =>
            {
                if (e.Button.Index == 1)
                {
                    //Disable
                    this.Enabled = false;
                    //
                    F_LoaiDV_Details FRM = new F_LoaiDV_Details();
                    FRM.isAction = "Add";
                    //FRM.ngaynhanmau = this.ngaynhanmau;
                    //FRM.KHMAUOBJ = this.KHMAUOBJ;
                    //FRM.KHMAUCTXNOBJ = this.KHMAUCTXNOBJ;
                    FRM.myFinished += this.finished;
                    FRM.Show();
                }
            };

            GrdLoaiMauGui.ButtonClick += (s, e) =>
            {
                if (e.Button.Index == 1)
                {
                    //Disable
                    this.Enabled = false;
                    //
                    F_LoaiMauGoi_Details FRM = new F_LoaiMauGoi_Details();
                    FRM.isAction = "Add";
                    this.Visible = false;
                    //FRM.ngaynhanmau = this.ngaynhanmau;
                    //FRM.KHMAUOBJ = this.KHMAUOBJ;
                    //FRM.KHMAUCTXNOBJ = this.KHMAUCTXNOBJ;
                    FRM.myFinished += this.finished;
                    FRM.Show();
                }
            };

            //Action_EndForm
            action_EndForm1.Add(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Add));
            action_EndForm1.Update(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Update));
            action_EndForm1.Close(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Close));
            action_EndForm1.Save(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Save));
            //Action_EndForm
            action_EndForm2.Add(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Add2));
            action_EndForm2.Update(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Update2));
            action_EndForm2.Close(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Close2));
            action_EndForm2.Save(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Save2));
            action_EndForm2.Delete(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Delete2));
            //Action_EndForm
            action_EndForm3.Add(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Add3));
            action_EndForm3.Update(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Update3));
            action_EndForm3.Close(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Close3));
            action_EndForm3.Save(new DevExpress.XtraBars.ItemClickEventHandler(ItemClickEventHandler_Save3));
        }