Exemple #1
0
        public PosMain(DataRow drUser)
        {
            AppCon ac = new AppCon();

            softwareType = ac.GetValue("SoftwareType");
            machineTable = ac.GetValue("MachineTable");
            if (softwareType == "SV" && machineTable == "")
            {
                messageBox msg = new messageBox("Lỗi", "Lỗi cấu hình", "Phải nhập thông tin Machine Table"); msg.ShowDialog();
            }
            InitializeComponent();
            m1.Visible      = false;
            m2.Visible      = false;
            m3.Visible      = false;
            m4.Visible      = false;
            m0_1.Visible    = false;
            m0_2.Visible    = false;
            header.Visible  = false;
            body.Visible    = false;
            body_1.Visible  = false;
            body_2.Visible  = false;
            footer.Visible  = false;
            loginUser       = drUser;
            casx.Text       = loginUser["Ca"].ToString();
            usrname.Text    = loginUser["HoTen"].ToString();
            timer1.Enabled  = true;
            timer1.Interval = 1000;
            timer2.Enabled  = true;
            timer2.Interval = 10000;
            timer3.Enabled  = true;
            timer3.Interval = 10000;
            machine.Text    = machineTable;
            type.Text       = softwareType;
        }
Exemple #2
0
        public AddForm(PosMain posMain)
        {
            AppCon ac = new AppCon();

            softwareType = ac.GetValue("SoftwareType");
            machineTable = ac.GetValue("MachineTable");
            if (softwareType == "SV" && machineTable == "")
            {
                messageBox msg = new messageBox("Lỗi", "Lỗi cấu hình", "Phải nhập thông tin Machine Table"); msg.ShowDialog();
            }
            InitializeComponent();
            mainFrm = posMain;
        }
Exemple #3
0
        private void m0_1_view_DoubleClick(object sender, EventArgs e)
        {
            DXMouseEventArgs ea   = e as DXMouseEventArgs;
            GridView         view = sender as GridView;
            GridHitInfo      info = view.CalcHitInfo(ea.Location);

            if (info.InRow || info.InRowCell)
            {
                string     colCaption = info.Column == null ? "N/A" : info.Column.GetCaption();
                string     macuonx    = view.GetRowCellValue(info.RowHandle, view.Columns["m0_1_MaCuon"]).ToString();
                string     kyhieu     = view.GetRowCellValue(info.RowHandle, view.Columns["m0_1_KyHieu"]).ToString();
                string     sokg       = view.GetRowCellValue(info.RowHandle, view.Columns["m0_1_SoKG"]).ToString();
                string     text       = macuonx + "\n" + kyhieu + "\n" + sokg;
                messageBox x          = new messageBox("Thông tin", "Cuộn giấy đang thao tác", text);
                x.ShowDialog();
                if (x.DialogResult != DialogResult.Cancel)
                {
                }
            }
        }
        private void ReturnData(string xmacuon)
        {
            string dataCnn1 = Config.GetValue("DataConnection").ToString();

            if (string.IsNullOrEmpty(dataCnn1))
            {
                messageBox msg = new messageBox("ConnErr", "Database Err", "Không tìm thấy chuỗi kết nối database");
                msg.ShowDialog();
                this.Close();
            }
            Database posDB   = Database.NewCustomDatabase(dataCnn1);
            string   machine = machineTable.Substring(0, 3).ToString();
            int      ms1     = Convert.ToInt32(posDB.GetValue(string.Format("SELECT count(ID) FROM {0}_D WHERE [MaCuon] = '{1}'", machine, xmacuon.Trim())));
            int      ms2     = Convert.ToInt32(posDB.GetValue(string.Format("SELECT count(ID) FROM {0}_E WHERE [MaCuon] = '{1}'", machine, xmacuon.Trim())));
            int      ms3     = Convert.ToInt32(posDB.GetValue(string.Format("SELECT count(ID) FROM {0}_B WHERE [MaCuon] = '{1}'", machine, xmacuon.Trim())));
            int      ms4     = Convert.ToInt32(posDB.GetValue(string.Format("SELECT count(ID) FROM {0}_C WHERE [MaCuon] = '{1}'", machine, xmacuon.Trim())));

            if (ms1 == 1)
            {
                UpdateData(xmacuon, "D");
            }
            else if (ms2 == 1)
            {
                UpdateData(xmacuon, "E");
            }
            else if (ms3 == 1)
            {
                UpdateData(xmacuon, "B");
            }
            else if (ms4 == 1)
            {
                UpdateData(xmacuon, "C");
            }
            else
            {
                messageBox msg = new messageBox("PaperErr", "Paper Err", "Không tìm thấy cuộn này trong bảng sử dụng");
                msg.ShowDialog();
                this.Close();
            }
        }
Exemple #5
0
        private void nhapCuon(string xmacuon, string may, int vitri)
        {
            // buoc 1: Lay thong tin cuon
            MaCuon mc      = new MaCuon();
            string dataCnn = Config.GetValue("DataConnection").ToString();

            dataCnn = dataCnn.Replace("POS", "HTCPH");
            Database hoaTieuDb = Database.NewCustomDatabase(dataCnn);

            mc.Macuon = xmacuon;
            //lay manvl + kho + ky hieu + ty le khoi
            var manl = hoaTieuDb.GetValue(string.Format("SELECT MaNL FROM DT42 WHERE MaCuon = '{0}'", xmacuon.Trim()));

            if (manl != null)
            {
                mc.MaNL = manl.ToString();
                DataTable dmNL = hoaTieuDb.GetDataTable(string.Format("SELECT KyHieu, Kho FROM wDMNL2 WHERE Ma = '{0}'", manl.ToString()));
                if (dmNL.Rows.Count > 0)
                {
                    mc.KyHieu = dmNL.Rows[0]["KyHieu"].ToString();
                    mc.Kho    = dmNL.Rows[0]["Kho"].ToString();
                }

                var tileK = hoaTieuDb.GetValue(string.Format("SELECT TiLeK from DMNL WHERE Ma = '{0}'", manl.ToString()));
                if (tileK != null)
                {
                    mc.TileK = Convert.ToDecimal(string.IsNullOrEmpty(tileK.ToString()) ? "0" : tileK.ToString());
                }
            }
            // lay so kg
            var     soTon      = hoaTieuDb.GetValue(string.Format("SELECT SoLuong FROM TonKhoNL WHERE MaCuon = '{0}'", xmacuon));
            decimal soluongTon = 0;

            if (soTon != null)
            {
                soluongTon = Convert.ToDecimal(soTon.ToString());
            }

            mc.SoKg = soluongTon;
            if (mc.SoKg == 0)
            {
                messageBox msg = new messageBox("PPEr", "Paper Err", "Cuộn vừa nhập đã sử dụng hết"); msg.ShowDialog();
                this.Close();
            }
            else
            {
                // check current list
                string dataCnn1 = Config.GetValue("DataConnection").ToString();
                if (string.IsNullOrEmpty(dataCnn1))
                {
                    messageBox msg = new messageBox("ConnErr", "Database Err", "Không tìm thấy chuỗi kết nối database");
                    msg.ShowDialog();
                    this.Close();
                }
                Database posDB   = Database.NewCustomDatabase(dataCnn1);
                string   machine = machineTable.Substring(0, 3).ToString();
                int      ms1     = Convert.ToInt32(posDB.GetValue(string.Format("SELECT count(ID) FROM {0}_D WHERE [MaCuon] = '{1}'", machine, xmacuon.Trim())));
                int      ms2     = Convert.ToInt32(posDB.GetValue(string.Format("SELECT count(ID) FROM {0}_E WHERE [MaCuon] = '{1}'", machine, xmacuon.Trim())));
                int      ms3     = Convert.ToInt32(posDB.GetValue(string.Format("SELECT count(ID) FROM {0}_B WHERE [MaCuon] = '{1}'", machine, xmacuon.Trim())));
                int      ms4     = Convert.ToInt32(posDB.GetValue(string.Format("SELECT count(ID) FROM {0}_C WHERE [MaCuon] = '{1}'", machine, xmacuon.Trim())));
                if ((ms1 + ms2 + ms3 + ms4) >= 1)
                {
                    messageBox msg = new messageBox("PPEr", "Paper Err", "Cuộn vừa nhập đang được sử dụng"); msg.ShowDialog();
                    this.Close();
                }
                else
                {
                    Database longwayDb = Database.NewStructDatabase();
                    int      startNum  = 0;
                    switch (may)
                    {
                    case "D": startNum = 0; break;

                    case "E":
                        switch (vitri)
                        {
                        case 1: startNum = 3; break;

                        case 2: startNum = 5; break;
                        }
                        break;

                    case "B":
                        switch (vitri)
                        {
                        case 1: startNum = 7; break;

                        case 2: startNum = 9; break;
                        }
                        break;

                    case "C":
                        switch (vitri)
                        {
                        case 1: startNum = 11; break;

                        case 2: startNum = 13; break;
                        }
                        break;

                    default:
                        break;
                    }
                    string    query = @"SELECT PaperUse, ProduceWid, CutNum, SumSquare, OrderNo FROM LW_Order
                WHERE SUBSTRING(PaperUse, {0}, 2) = '{1}' and ProduceWid = {2} ";
                    DataTable order = longwayDb.GetDataTable(string.Format(query, startNum, mc.KyHieu, mc.Kho));
                    if (order == null || order.Rows.Count == 0)
                    {
                        messageBox msg = new messageBox("PPEr", "Paper Err", "Cuộn này không có trong kế hoạch sản xuất, Yêu cầu Admin Xác nhận"); msg.ShowDialog();
                        if (msg.DialogResult != DialogResult.Cancel)
                        {
                            if (!mainFrm.IsQuanLy())
                            {
                                //Login frmLogin = new Login();
                                //frmLogin.StartPosition = FormStartPosition.CenterScreen;
                                //frmLogin.ShowDialog();
                                AdminConfirm frmConfirm = new AdminConfirm();
                                frmConfirm.StartPosition = FormStartPosition.CenterScreen;
                                frmConfirm.ShowDialog();
                                //dang nhap lai quyen quan ly
                                if (frmConfirm.DialogResult != DialogResult.Cancel)
                                {
                                    if (!frmConfirm.confUser["Quyen"].ToString().Equals("Quản lý"))
                                    {
                                        MessageBox.Show("Chức năng này chỉ dành cho quản lý", "POS Warning");
                                        this.Close();
                                    }
                                    else
                                    {
                                        mc.Duyet = frmConfirm.confUser["HoTen"].ToString();
                                        LoadToData(mc, may, vitri);
                                    }
                                }
                                else
                                {
                                    this.Close();
                                }
                            }
                            else
                            {
                                mc.Duyet = mainFrm.loginUser["HoTen"].ToString();
                                LoadToData(mc, may, vitri);
                            }
                        }
                        this.Close();
                    }
                    else
                    {
                        LoadToData(mc, may, vitri);
                    }
                }// check longway
            }
        }