Ejemplo n.º 1
0
        private void btn_repay_Click(object sender, EventArgs e)
        {
            if (_credit == 0)
            {
                AutoClosingMessageBox.Show("此會員目前無賒帳金額");
                return;
            }
            if ("請輸入還款金額".Equals(tb_repay.Text))
            {
                AutoClosingMessageBox.Show("請先輸入賒帳還款數字");
                return;
            }
            int    num   = int.Parse(tb_repay.Text);
            string text  = "0";
            string text2 = "0";
            string sql   = "";

            if (_credit <= num)
            {
                sql   = "UPDATE hypos_CUST_RTL SET Credit={1} where VipNo={0} ";
                text2 = (num - _credit).ToString();
                AutoClosingMessageBox.Show("賒帳還款「" + num + "」,還款後賒帳金額為"0",需找零"" + text2 + """);
            }
            if (_credit > num)
            {
                sql  = "UPDATE hypos_CUST_RTL SET Credit=Credit+{1} where VipNo={0} ";
                text = (-num).ToString();
                AutoClosingMessageBox.Show("賒帳還款「" + num + "」,還款後賒帳金額為"" + (_credit - num) + """);
            }
            DataBaseUtilities.DBOperation(Program.ConnectionString, sql, new string[2]
            {
                _vipNo,
                text
            }, CommandOperationType.ExecuteNonQuery);
            string text3 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            string[,] strFieldArray = new string[7, 2]
            {
                {
                    "memberId",
                    _vipNo
                },
                {
                    "sellNo",
                    ""
                },
                {
                    "editdate",
                    text3
                },
                {
                    "sellType",
                    "2"
                },
                {
                    "Cash",
                    text2
                },
                {
                    "Credit",
                    num.ToString()
                },
                {
                    "status",
                    "0"
                }
            };
            DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Insert, "", "hypos_user_consumelog", "", "", strFieldArray, null, CommandOperationType.ExecuteNonQuery);
            DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_CUST_RTL SET RepayDate = {1} WHERE VipNo = {0}", new string[2]
            {
                _vipNo,
                text3
            }, CommandOperationType.ExecuteNonQuery);
            _frmEM.repayChange();
            Hide();
            _frmEM.Show();
        }
Ejemplo n.º 2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            AuthResultObject authResultObject = ws.hasInUseFirst(RegisterCode);

            string[] strParameterArray = new string[2]
            {
                RegisterCode,
                DateTime.Now.ToString()
            };
            if (bool.Parse(authResultObject.inUse))
            {
                AutoClosingMessageBox.Show(authResultObject.message);
                Program.LincenseCode = txtLicenseCode.Text;
                Program.SiteNo       = authResultObject.serial.PadLeft(2, '0');
                Program.ShopType     = authResultObject.shopType;
                DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_RegisterLicense SET isApproved = 'Y', ApproveDate = {1} where RegisterCode = {0} ", strParameterArray, CommandOperationType.ExecuteNonQuery);
                DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_SysParam SET SiteNo = {0} ", new string[1]
                {
                    authResultObject.serial.PadLeft(2, '0')
                }, CommandOperationType.ExecuteNonQuery);
                if (!string.IsNullOrEmpty(Program.ShopType))
                {
                    string sql = "SELECT ShopIdNo FROM hypos_ShopInfoManage";
                    if (((DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, sql, null, CommandOperationType.ExecuteReaderReturnDataTable)).Rows.Count > 0)
                    {
                        if (Program.ShopType.Equals("0"))
                        {
                            DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_ShopInfoManage SET IsRetailer = {0}, IsWholesaler = {1} ", new string[2]
                            {
                                "ON",
                                "ON"
                            }, CommandOperationType.ExecuteNonQuery);
                        }
                        else if (Program.ShopType.Equals("1"))
                        {
                            DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_ShopInfoManage SET IsRetailer = {0}, IsWholesaler = {1} ", new string[2]
                            {
                                "ON",
                                "OFF"
                            }, CommandOperationType.ExecuteNonQuery);
                        }
                        else if (Program.ShopType.Equals("2"))
                        {
                            DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_ShopInfoManage SET IsRetailer = {0}, IsWholesaler = {1} ", new string[2]
                            {
                                "OFF",
                                "ON"
                            }, CommandOperationType.ExecuteNonQuery);
                        }
                    }
                    else if (Program.ShopType.Equals("0"))
                    {
                        DataBaseUtilities.DBOperation(Program.ConnectionString, "INSERT INTO hypos_ShopInfoManage ( IsRetailer, IsWholesaler) VALUES( {0}, {1})", new string[2]
                        {
                            "ON",
                            "ON"
                        }, CommandOperationType.ExecuteNonQuery);
                    }
                    else if (Program.ShopType.Equals("1"))
                    {
                        DataBaseUtilities.DBOperation(Program.ConnectionString, "INSERT INTO hypos_ShopInfoManage ( IsRetailer, IsWholesaler) VALUES( {0}, {1}) ", new string[2]
                        {
                            "ON",
                            "OFF"
                        }, CommandOperationType.ExecuteNonQuery);
                    }
                    else if (Program.ShopType.Equals("2"))
                    {
                        DataBaseUtilities.DBOperation(Program.ConnectionString, "INSERT INTO hypos_ShopInfoManage ( IsRetailer, IsWholesaler) VALUES( {0}, {1}) ", new string[2]
                        {
                            "OFF",
                            "ON"
                        }, CommandOperationType.ExecuteNonQuery);
                    }
                }
                new frmDownload(Program.LincenseCode, "").ShowDialog();
                if (Program.IsDataTransfer)
                {
                    string value  = DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT SystemMode FROM hypos_SysParam", null, CommandOperationType.ExecuteScalar).ToString();
                    string value2 = DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT IsDataTransfer FROM hypos_SysParam", null, CommandOperationType.ExecuteScalar).ToString();
                    if (!"Y".Equals(value2) && "".Equals(value))
                    {
                        frmDataTransfer frmDataTransfer = new frmDataTransfer();
                        frmDataTransfer.Location = new Point(base.Location.X, base.Location.Y);
                        frmDataTransfer.ShowDialog();
                        if (File.Exists("C:\\Hypos\\Old_db.db3") && File.Exists("C:\\Hypos\\conn_log.txt"))
                        {
                            try
                            {
                                using (StreamReader streamReader = new StreamReader("C:\\\\Hypos\\\\conn_log.txt", Encoding.Unicode))
                                {
                                    string text = streamReader.ReadToEnd();
                                    if ("1".Equals(text.Substring(0, 1)))
                                    {
                                        try
                                        {
                                            AutoBackupDT();
                                            new dbDataTransfer().ShowDialog();
                                            DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_SysParam SET IsDataTransfer = 'Y'", null, CommandOperationType.ExecuteNonQuery);
                                        }
                                        catch (Exception ex)
                                        {
                                            MessageBox.Show(string.Format("dbDataTransfer發生例外狀況:「{0}」", ex.ToString()));
                                        }
                                    }
                                    else if ("2".Equals(text.Substring(0, 1)))
                                    {
                                        DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_SysParam SET IsDataTransfer = 'Y'", null, CommandOperationType.ExecuteNonQuery);
                                        MessageBox.Show("舊POS資料移轉程序已取消");
                                    }
                                    else
                                    {
                                        MessageBox.Show("舊POS系統資料匯入SQLite失敗。");
                                    }
                                }
                            }
                            catch (Exception ex2)
                            {
                                MessageBox.Show(string.Format("開啟紀錄檔發生例外狀況:「{0}」", ex2.ToString()));
                            }
                        }
                        else if (File.Exists("C:\\Hypos\\conn_log.txt"))
                        {
                            try
                            {
                                using (StreamReader streamReader2 = new StreamReader("C:\\\\Hypos\\\\conn_log.txt", Encoding.Unicode))
                                {
                                    string text2 = streamReader2.ReadToEnd();
                                    if (!"2".Equals(text2.Substring(0, 1)))
                                    {
                                        MessageBox.Show("移轉程序失敗並結束。");
                                        return;
                                    }
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
                switchForm(new frmLogin());
            }
            else
            {
                AutoClosingMessageBox.Show(authResultObject.message);
                if ("ERROR_BAN".Equals(authResultObject.errorCode) || "ERROR_UNUSE".Equals(authResultObject.errorCode) || "ERROR_EMPTY".Equals(authResultObject.errorCode))
                {
                    DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_RegisterLicense SET isApproved = 'N', ApproveDate = {1} where RegisterCode = {0} ", strParameterArray, CommandOperationType.ExecuteNonQuery);
                    btnSubmit.Enabled      = false;
                    btnUploadSysSN.Enabled = true;
                    btnReset.Enabled       = true;
                    txtLicenseCode.Enabled = true;
                    txtShopName.Enabled    = true;
                    btnSubmit.BackColor    = Color.DimGray;
                }
            }
        }
Ejemplo n.º 3
0
        private void btnUploadSysSN_Click(object sender, EventArgs e)
        {
            string text = "";

            if (txtLicenseCode.Text == "請輸入販賣執照證號")
            {
                text += "請輸入販賣執照證號 \n";
            }
            if (txtShopName.Text == "請輸入商家商業名稱")
            {
                text += "請輸入商家商業名稱";
            }
            if (text != "")
            {
                AutoClosingMessageBox.Show(text);
                return;
            }
            string         text2          = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff");
            RegisterObject registerObject = new RegisterObject();

            registerObject.license     = txtLicenseCode.Text;
            registerObject.name        = txtShopName.Text;
            registerObject.hddSerialId = Program.HardDiskSerialNo;
            registerObject.applyTime   = text2;
            string text3 = Program.Encrypt(JsonConvert.SerializeObject(registerObject, Formatting.Indented));

            string[,] strFieldArray = new string[5, 2]
            {
                {
                    "RegisterCode",
                    text3
                },
                {
                    "LicenseCode",
                    registerObject.license
                },
                {
                    "ShopName",
                    registerObject.name
                },
                {
                    "HardDiskSerialNo",
                    registerObject.hddSerialId
                },
                {
                    "CreateDate",
                    text2
                }
            };
            DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Insert, "", "hypos_RegisterLicense", "", "", strFieldArray, null, CommandOperationType.ExecuteNonQuery);
            RegisterResultObject registerResultObject = ws.uploadApplySerial(text3);

            if (bool.Parse(registerResultObject.isSuccess))
            {
                AutoClosingMessageBox.Show(registerResultObject.message);
                btnSubmit.Enabled      = true;
                btnUploadSysSN.Enabled = false;
                btnReset.Enabled       = false;
                txtLicenseCode.Enabled = false;
                txtShopName.Enabled    = false;
                btnSubmit.BackColor    = Color.FromArgb(0, 153, 204);
                RegisterCode           = text3;
            }
            else
            {
                AutoClosingMessageBox.Show("上傳失敗:\n" + registerResultObject.message);
            }
        }
        private void btn_ExportCustflowReport_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

            if (folderBrowserDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string   selectedPath = folderBrowserDialog.SelectedPath;
            string   text         = selectedPath + str_file_location + str_file_name + _strFromDate.Replace("-", "") + "-" + _strToDate.Replace("-", "") + str_file_type;
            FileInfo file         = new FileInfo(text);
            int      num          = 2;

            if (!File.Exists(text))
            {
                wb = HSSFWorkbook.Create(InternalWorkbook.CreateWorkbook());
                sh = (HSSFSheet)wb.CreateSheet("Sheet1");
                for (int i = 0; i < dataGridView2.RowCount + num; i++)
                {
                    IRow row = sh.CreateRow(i);
                    for (int j = 0; j < dataGridView2.ColumnCount; j++)
                    {
                        row.CreateCell(j);
                    }
                }
                using (FileStream @out = new FileStream(text, FileMode.Create, FileAccess.Write))
                {
                    wb.Write(@out);
                }
            }
            if (!IsFileLocked(file))
            {
                using (FileStream s = new FileStream(text, FileMode.Open, FileAccess.Read))
                {
                    wb = new HSSFWorkbook(s);
                    for (int k = 0; k < wb.Count; k++)
                    {
                        lst_Sheet.Add(wb.GetSheetAt(k).SheetName);
                    }
                }
            }
            if (!IsFileLocked(file))
            {
                sh = (HSSFSheet)wb.GetSheet(lst_Sheet[0]);
                int      l     = 0;
                string[] array = new string[9]
                {
                    "日期:",
                    _strFromDate + "~" + _strToDate,
                    "特定廠商:",
                    _member_name,
                    "廠商類型:",
                    _member_type,
                    "廠商狀態:",
                    _member_status,
                    ""
                };
                string[] array2 = new string[9]
                {
                    "出貨對象(廠商)",
                    "出貨總額(原始)",
                    "出貨次",
                    "品項數",
                    "出貨數量",
                    " ",
                    " ",
                    " ",
                    " "
                };
                int num2 = (array.Length > array2.Length) ? array.Length : array2.Length;
                for (; l < num; l++)
                {
                    for (int m = 0; m < num2; m++)
                    {
                        if (sh.GetRow(l).GetCell(m) == null)
                        {
                            sh.GetRow(l).CreateCell(m);
                        }
                        if (l == 0)
                        {
                            sh.GetRow(l).GetCell(m).SetCellValue(array[m]);
                        }
                        if (l == 1)
                        {
                            sh.GetRow(l).GetCell(m).SetCellValue(array2[m]);
                        }
                    }
                }
                for (int n = 0; n < dataGridView2.RowCount; n++)
                {
                    if (sh.GetRow(l) == null)
                    {
                        sh.CreateRow(l);
                    }
                    for (int num3 = 0; num3 < dataGridView2.ColumnCount; num3++)
                    {
                        if (sh.GetRow(l).GetCell(num3) == null)
                        {
                            sh.GetRow(l).CreateCell(num3);
                        }
                        if (dataGridView2[num3, n].Value != null)
                        {
                            sh.GetRow(l).GetCell(num3).SetCellValue(dataGridView2[num3, n].Value.ToString());
                        }
                    }
                    l++;
                }
                using (FileStream out2 = new FileStream(text, FileMode.Open, FileAccess.Write))
                {
                    wb.Write(out2);
                    AutoClosingMessageBox.Show("匯出報表於" + text);
                }
            }
            else
            {
                AutoClosingMessageBox.Show(text + "檔案使用中,請確認檔案是在未開啟的狀態下");
            }
        }