private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string sourceChaseNo = lblChaseno.Text;

                string  mouldno  = txtMouldno.Text;
                string  itemcode = txtItemcode.Text;
                string  rev      = txtRev.Text;
                decimal amount   = Convert.ToDecimal(txtAmount.Text);
                string  oemasset = txtOemasset.Text;
                string  remarks  = txtRemarks.Text;
                string  pcs      = txtPcs.Text;
                string  type     = txtType.Text;
                //string owner = txtOwner.Text;
                string owner  = cbOwner.SelectedItem.ToString();
                string pgroup = cbGroup.SelectedItem.ToString();
                string vendor = txtVendor.Text;

                string mouldcode = txtMouldCode.Text;

                string model = gModel;

                if (rev.Length == 1)
                {
                    rev = "0" + rev;
                }

                string modify = "";

                if (ckbModify.Checked)
                {
                    modify = "True";
                }
                else
                {
                    modify = "False";
                }

                bool mpa;

                if (ckbMpa.Checked)
                {
                    mpa = true;
                }
                else
                {
                    mpa = false;
                }

                if (!DataChecking.isValidVendor(vendor))
                {
                    MessageBox.Show("Invalid vendor code");
                    return;
                }

                if (!DataChecking.isValidMouldCode(mouldcode))
                {
                    MessageBox.Show("Invalid mould code");
                    return;
                }

                string curr = "";

                string year    = DateTime.Today.ToString("yyyy");
                string month   = DateTime.Today.ToString("MM");
                string jpyrate = DataChecking.getJpyRate(year, month);

                if (lblCurrency.Text.Contains("JPY"))
                {
                    curr = "JPY";
                }
                else
                {
                    curr = DataChecking.getCurrency(vendor);
                }

                decimal calAmount = 0;

                if (lblCurrency.Text.Contains("JPY"))
                {
                    calAmount = Convert.ToDecimal(amount) * Convert.ToDecimal(jpyrate);
                }
                else
                {
                    calAmount = DataChecking.amountWithRate(curr, amount.ToString());
                }

                string itemtext = "";

                if (!mpa)
                {
                    itemtext = mouldno + "MP+" + mouldcode + "+Modify";
                }
                else
                {
                    itemtext = mouldno + "MP+" + mouldcode + "+Modify*";
                }

                string projecttext = itemcode + "-" + rev;
                string request     = itemcode + rev;

                decimal tmpAmount = amount / Convert.ToInt32(pcs);

                //string currency = DataChecking.getCurrency(vendor);

                //string common = DataChecking.getCommon(mouldno, itemcode);
                string common = DataChecking.getCommonByMouldNo(mouldno);

                string quantity = "";

                calAmount = calAmount / Convert.ToInt32(pcs);

                string amounthkd = calAmount.ToString("#.##");

                quantity = Convert.ToDecimal(amounthkd) >= 10000 && mpa ? "2" : "1";

                string qstatus  = "";
                string category = "A";

                decimal tax = 0;

                string chaseno = sourceChaseNo.StartsWith("CM") ? DataChecking.GetLastCnChaseNo() : DataChecking.getLastChaseNo();

                string accountcode = sourceChaseNo.StartsWith("CM") ? "" : "5005020002";
                string costcentre  = sourceChaseNo.StartsWith("CM") ? "" : "1404000029";

                if (sourceChaseNo.StartsWith("CM"))
                {
                    qstatus = "U";

                    amounthkd = "-";

                    double ta = Convert.ToDouble(amount);

                    category = ta >= 5000 ? "A" : "K";

                    tax = Convert.ToDecimal(ta * 0.17);
                }
                else
                {
                    if (calAmount < 10000)
                    {
                        if (calAmount == 0)
                        {
                            qstatus = "K";
                        }
                        else
                        {
                            qstatus = "U";
                        }

                        category = "K";
                    }
                    else
                    {
                        if (mouldcode.StartsWith("8") && mouldcode != "8")
                        {
                            qstatus  = "U";
                            category = "K";
                        }
                        else if (oemasset != "")
                        {
                            qstatus  = "U";
                            category = "K";
                        }
                        else
                        {
                            qstatus     = "F";
                            accountcode = "";
                            costcentre  = "";
                            category    = "A";
                        }
                    }
                }

                if (oemasset != "")
                {
                    if (oemasset.Length == 1)
                    {
                        oemasset = "0" + oemasset;
                    }

                    if (!DataChecking.validOem(oemasset))
                    {
                        MessageBox.Show("Invalid OEM");
                        return;
                    }

                    accountcode = DataChecking.getAccountCode(oemasset);
                    costcentre  = DataChecking.getCostCentre(oemasset);
                }

                //string model = itemcode.Substring(2, 3);

                string insertText = string.Format("insert into tb_betamould (tm_chaseno, tm_mouldno, tm_itemcode, tm_rev, tm_status, tm_type, tm_currency, tm_amount, tm_amounthkd" +
                                                  ", tm_mpa, tm_mouldcode_code, tm_vendor_code, tm_st_code, tm_qty, tm_itemtext, tm_projecttext, tm_request, tm_owner, tm_category, tm_indate, tm_common, tm_oemasset, tm_rm, tm_createdby, tm_model, tm_group, tm_accountcode, tm_costcentre, tm_ismodify, tm_pcs) values" +
                                                  " ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', N'{22}', N'{23}', '{24}', '{25}', '{26}', '{27}', '{28}', '{29}')", chaseno, mouldno, itemcode, rev, "Modify", type,
                                                  curr, amount, amounthkd, mpa, mouldcode, vendor, qstatus, quantity, itemtext, projecttext, request, owner, category, DateTime.Today.ToString("yyyy/MM/dd"), common, oemasset, remarks, AdUtil.getUsername("kmhk.local"), model, pgroup, accountcode, costcentre, modify, pcs);
                DataService.GetInstance().ExecuteNonQuery(insertText);

                string logText = string.Format("insert into tb_log (log_module, log_fromvalue, log_tovalue, log_user, log_datetime, log_chaseno, log_message)" +
                                               " values ('{0}', '{1}', '{2}', N'{3}', '{4}', '{5}', '{6}')", "Quotation", "-", "-", AdUtil.getUsername("kmhk.local"), DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), chaseno, "Modify Item");

                DataService.GetInstance().ExecuteNonQuery(logText);

                MessageBox.Show("Record has been saved");

                if (formClose != null)
                {
                    formClose(this, new EventArgs());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
        private void loadData(string chaseno)
        {
            string query = string.Format("select tm_mouldno, tm_itemcode, tm_rev" +
                                         ", tm_oemasset, tm_remarks, tm_vendor_code, tm_mouldcode_code, tm_status, tm_type, tm_owner, tm_model from tb_betamould where tm_chaseno = '{0}'", chaseno);

            Debug.WriteLine(query);
            string mouldno = "", itemcode = "", rev = "", oemasset = "", remarks = "", vendor = "", mouldcode = "", status = "", type = "", owner = "";

            GlobalService.reader = DataService.GetInstance().ExecuteReader(query);

            while (GlobalService.reader.Read())
            {
                mouldno   = GlobalService.reader.GetString(0);
                itemcode  = GlobalService.reader.GetString(1);
                rev       = GlobalService.reader.GetString(2);
                oemasset  = GlobalService.reader.GetString(3);
                remarks   = GlobalService.reader.GetString(4);
                vendor    = GlobalService.reader.GetString(5);
                mouldcode = GlobalService.reader.GetString(6);
                status    = GlobalService.reader.GetString(7);
                type      = GlobalService.reader.GetString(8);
                owner     = GlobalService.reader.GetString(9);
                gModel    = GlobalService.reader.GetString(10);
            }
            GlobalService.reader.Close();
            GlobalService.reader.Dispose();

            //if (status == "New" || status == "Modify")
            // txtDiv.Text = "Modify";

            txtDiv.Text  = "Modify";
            txtType.Text = type;

            lblChaseno.Text  = chaseno.StartsWith("CM") ? DataChecking.GetLastCnChaseNo() : DataChecking.getLastChaseNo();
            txtMouldno.Text  = mouldno;
            txtItemcode.Text = itemcode;
            txtOemasset.Text = oemasset;
            txtRemarks.Text  = remarks;

            txtVendor.Text     = vendor;
            lblVendorname.Text = DataChecking.getVendorName(vendor);
            lblGroup.Text      = DataChecking.getVendorGroup(vendor);
            lblPurchaser.Text  = DataChecking.getVendorPerson(vendor);
            lblCurrency.Text   = DataChecking.getCurrency(vendor);

            cbOwner.SelectedItem = owner;

            try
            {
                cbGroup.Items.Clear();
                string singleGroup = DataChecking.getVendorGroup(vendor);
                string text        = string.Format("select v_remarks from tb_vendor where v_code = '{0}'", vendor);

                GlobalService.reader = DataService.GetInstance().ExecuteReader(text);

                if (GlobalService.reader.HasRows)
                {
                    while (GlobalService.reader.Read())
                    {
                        remarks = GlobalService.reader.GetString(0);
                    }
                }

                GlobalService.reader.Close();
                GlobalService.reader.Dispose();

                if (remarks != "")
                {
                    string[] remark = Split(remarks);
                    foreach (string item in remark)
                    {
                        cbGroup.Items.Add(item);
                    }
                }
                else
                {
                    cbGroup.Items.Add(singleGroup);
                }

                cbGroup.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message + ex.StackTrace);
            }

            txtMouldCode.Text = mouldcode;
            this.loadMouldCode(mouldcode);
        }
Beispiel #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dgvQuotationDetail.Rows)
            {
                string mouldno   = row.Cells[0].Value.ToString();
                string itemcode  = row.Cells[1].Value.ToString();
                string rev       = row.Cells[2].Value.ToString();
                string model     = row.Cells[3].Value.ToString();
                string status    = row.Cells[4].Value.ToString();
                string currency  = row.Cells[6].Value.ToString();
                string amount    = row.Cells[7].Value.ToString();
                string mpa       = row.Cells[8].FormattedValue.ToString();
                string vendor    = row.Cells[9].Value.ToString();
                string mouldcode = row.Cells[5].Value.ToString();
                string oemasset  = row.Cells[10].Value.ToString();
                string remarks   = row.Cells[11].Value.ToString();
                //string setmould = row.Cells[11].Value.ToString();
                string accountcode = row.Cells[12].Value.ToString();
                string costcentre  = row.Cells[13].Value.ToString();
                string pcs         = row.Cells[14].Value.ToString();

                string pgroup = cbGroup.SelectedItem.ToString();
                string modify = row.Cells[15].FormattedValue.ToString();

                string setitemcode = row.Cells[16].Value.ToString();

                string vnonly   = row.Cells[17].Value.ToString();
                string cnvnonly = row.Cells[18].Value.ToString();

                string owner = row.Cells[19].Value.ToString().Trim();
                string is50  = row.Cells[20].Value.ToString().Trim();

                string projecttext = itemcode + "-" + rev;
                string request     = itemcode + rev;

                string chaseno = owner == "KDTCN" ? DataChecking.GetLastCnChaseNo() : DataChecking.getLastChaseNo();

                string itemtext = "";
                string type     = "Single";

                if (!string.IsNullOrEmpty(setitemcode) && setitemcode != "" && setitemcode != "N/A")
                {
                    type = "Set";
                }

                string instockdate50 = "";

                if (mpa == "False")
                {
                    itemtext      = mouldno + "MP+" + mouldcode + "+" + status;
                    instockdate50 = "#N/A";
                }
                else
                {
                    itemtext      = mouldno + "MP+" + mouldcode + "+" + status + "*";
                    instockdate50 = "Yes";
                }

                string quantity = "";

                string qstatus  = "";
                string category = "A";

                decimal calAmount = 0;
                string  year      = DateTime.Today.ToString("yyyy");
                string  month     = DateTime.Today.ToString("MM");
                string  jpyrate   = DataChecking.getJpyRate(year, month);

                if (transferMode == "From KDC")
                {
                    calAmount = Convert.ToDecimal(amount) * Convert.ToDecimal(jpyrate);
                }
                else
                {
                    calAmount = DataChecking.amountWithRate(currency, amount);
                }

                string amounthkd = calAmount.ToString("#.##");

                quantity = Convert.ToDecimal(amounthkd) >= 10000 && mpa == "True" ? "2" : "1";

                int piece = Convert.ToInt32(pcs);

                calAmount = calAmount / piece;

                string po = "";

                decimal tax = 0;

                if (owner == "KDTCN")
                {
                    qstatus = "U";

                    amounthkd = "-";

                    double ta = Convert.ToDouble(amount);

                    category = ta >= 5000 ? "A" : "K";

                    tax = Convert.ToDecimal(ta * 0.17);
                }
                else
                {
                    if (calAmount < 10000)
                    {
                        if (calAmount == 0)
                        {
                            qstatus = "K";
                        }
                        else
                        {
                            qstatus = "U";
                        }

                        category = "K";
                    }
                    else
                    {
                        if (mouldcode.StartsWith("8") && mouldcode != "8")
                        {
                            qstatus  = "U";
                            category = "K";
                        }
                        else if (oemasset != "")
                        {
                            qstatus  = "U";
                            category = "K";
                        }
                        else
                        {
                            qstatus = "F";
                        }
                    }


                    if (status == "TM")
                    {
                        qstatus = "T";
                        if (calAmount < 10000)
                        {
                            category = "K";
                        }

                        else
                        {
                            category = "A";
                            qstatus  = "F";
                        }

                        po = chaseno.Replace("MS", "TM");
                    }
                }

                string common = "Non-Common";

                string insertText = "";

                if (accountcode == "N/A")
                {
                    accountcode = "";
                }

                if (costcentre == "N/A")
                {
                    costcentre = "";
                }

                if ((mpa == "True" || is50 == "Yes") && owner == "KDTCN")
                {
                    //double tmAmount = Convert.ToDouble(amount) / 2;
                    //double tmTax = Convert.ToDouble(tax) / 2;

                    if (!itemtext.EndsWith("*"))
                    {
                        itemtext = itemtext + "*";
                    }

                    insertText = string.Format("insert into tb_betamould (tm_chaseno, tm_mouldno, tm_itemcode, tm_rev, tm_status, tm_type, tm_currency, tm_amount, tm_amounthkd" +
                                               ", tm_mpa, tm_mouldcode_code, tm_vendor_code, tm_st_code, tm_qty, tm_itemtext, tm_projecttext, tm_request, tm_owner, tm_category, tm_indate, tm_common, tm_oemasset, tm_rm, tm_createdby, tm_model, tm_group, tm_accountcode, tm_costcentre, tm_ismodify, tm_instockdate50, tm_pcs, tm_po, tm_vnonly, tm_cnvnonly, tm_is50, tm_tax, tm_checkdate2) values" +
                                               " ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', N'{22}', N'{23}', '{24}', '{25}', '{26}', '{27}', '{28}', '{29}', '{30}', '{31}', '{32}', '{33}', '{34}', '{35}', '{36}')", chaseno, mouldno, itemcode, rev, status, type,
                                               currency, amount, amounthkd, mpa, mouldcode, vendor, qstatus, "1", itemtext, projecttext, request, owner, category, DateTime.Today.ToString("yyyy/MM/dd"), common, oemasset, remarks, AdUtil.getUsername("kmhk.local"), model, pgroup, accountcode, costcentre, modify, instockdate50, pcs, po, vnonly, cnvnonly, is50, tax, pgroup);
                    DataService.GetInstance().ExecuteNonQuery(insertText);

                    /*string is50ChaseNo = DataChecking.GetLastCnChaseNo();
                     *
                     * string insertText2 = string.Format("insert into tb_betamould (tm_chaseno, tm_mouldno, tm_itemcode, tm_rev, tm_status, tm_type, tm_currency, tm_amount, tm_amounthkd" +
                     *  ", tm_mpa, tm_mouldcode_code, tm_vendor_code, tm_st_code, tm_qty, tm_itemtext, tm_projecttext, tm_request, tm_owner, tm_category, tm_indate, tm_common, tm_oemasset, tm_rm, tm_createdby, tm_model, tm_group, tm_accountcode, tm_costcentre, tm_ismodify, tm_instockdate50, tm_pcs, tm_po, tm_vnonly, tm_cnvnonly, tm_is50, tm_tax, tm_checkdate2) values" +
                     *  " ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', N'{22}', N'{23}', '{24}', '{25}', '{26}', '{27}', '{28}', '{29}', '{30}', '{31}', '{32}', '{33}', '{34}', '{35}', '{36}')", is50ChaseNo, mouldno, itemcode, rev, status, type,
                     *  currency, tmAmount, amounthkd, mpa, mouldcode, vendor, qstatus, "1", itemtext, projecttext, request, owner, category, DateTime.Today.ToString("yyyy/MM/dd"), common, oemasset, remarks, AdUtil.getUsername("kmhk.local"), model, pgroup, accountcode, costcentre, modify, instockdate50, pcs, po, vnonly, cnvnonly, is50, tmTax, pgroup);
                     * DataService.GetInstance().ExecuteNonQuery(insertText2);*/
                }
                else
                {
                    insertText = string.Format("insert into tb_betamould (tm_chaseno, tm_mouldno, tm_itemcode, tm_rev, tm_status, tm_type, tm_currency, tm_amount, tm_amounthkd" +
                                               ", tm_mpa, tm_mouldcode_code, tm_vendor_code, tm_st_code, tm_qty, tm_itemtext, tm_projecttext, tm_request, tm_owner, tm_category, tm_indate, tm_common, tm_oemasset, tm_rm, tm_createdby, tm_model, tm_group, tm_accountcode, tm_costcentre, tm_ismodify, tm_instockdate50, tm_pcs, tm_po, tm_vnonly, tm_cnvnonly, tm_is50, tm_tax, tm_checkdate2) values" +
                                               " ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', N'{22}', N'{23}', '{24}', '{25}', '{26}', '{27}', '{28}', '{29}', '{30}', '{31}', '{32}', '{33}', '{34}', '{35}', '{36}')", chaseno, mouldno, itemcode, rev, status, type,
                                               currency, amount, amounthkd, mpa, mouldcode, vendor, qstatus, quantity, itemtext, projecttext, request, owner, category, DateTime.Today.ToString("yyyy/MM/dd"), common, oemasset, remarks, AdUtil.getUsername("kmhk.local"), model, pgroup, accountcode, costcentre, modify, instockdate50, pcs, po, vnonly, cnvnonly, is50, tax, pgroup);
                    DataService.GetInstance().ExecuteNonQuery(insertText);
                }

                if (!string.IsNullOrEmpty(setitemcode) && setitemcode != "" && setitemcode != "N/A")
                {
                    string setText = string.Format("if not exists (select * from tb_setcommon where sc_itemcode = '{0}' and sc_mouldno = '{1}') begin" +
                                                   " insert into tb_setcommon (sc_itemcode, sc_mouldno, sc_oldmouldno, sc_type) values ('{0}', '{1}', '{1}', 'Set') end", setitemcode, mouldno, mouldno);

                    DataService.GetInstance().ExecuteNonQuery(setText);
                }

                if (oemasset != "")
                {
                    string oemcontent = DataChecking.getOemContent(oemasset);
                    string vendorname = DataChecking.getVendorName(vendor);

                    string query = String.Format("insert into tb_expensetransfer(et_date, et_asset, et_partno, et_rev, et_mouldno, et_type, et_mouldcode, et_cur, et_amount" +
                                                 ", et_vendorcode, et_vendor, et_chaseno, et_remarks) values ('{0}', '{1}', '{2}', '{3}'" +
                                                 ", '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}')", DateTime.Today.ToString("yyyy/MM/dd"), oemcontent, itemcode,
                                                 rev, mouldno, status, mouldcode, currency, amount, vendor, vendorname, chaseno, remarks);

                    DataService.GetInstance().ExecuteNonQuery(query);
                }

                /*if (setmould == "False")
                 * {
                 *  insertText = string.Format("insert into tb_betamould (tm_chaseno, tm_mouldno, tm_itemcode, tm_rev, tm_status, tm_type, tm_currency, tm_amount, tm_amounthkd" +
                 *      ", tm_mpa, tm_mouldcode_code, tm_vendor_code, tm_st_code, tm_qty, tm_itemtext, tm_projecttext, tm_request, tm_owner, tm_category, tm_indate, tm_common, tm_oemasset, tm_rm, tm_createdby, tm_model, tm_group, tm_accountcode, tm_costcentre) values" +
                 *      " ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', '{22}', '{23}', '{24}', '{25}', '{26}', '{27}')", chaseno, mouldno, itemcode, rev, status, type,
                 *      currency, amount, amounthkd, mpa, mouldcode, vendor, qstatus, quantity, itemtext, projecttext, request, owner, category, DateTime.Today.ToString("yyyy/MM/dd"), common, oemasset, remarks, AdUtil.getUsername("kmhk.local"), model, pgroup, accountcode, costcentre);
                 *  DataService.GetInstance().ExecuteNonQuery(insertText);
                 * }
                 * else
                 * {
                 *  insertText = string.Format("insert into tb_betamould (tm_chaseno, tm_mouldno, tm_itemcode, tm_rev, tm_status, tm_type, tm_currency, tm_amount, tm_amounthkd" +
                 *      ", tm_mpa, tm_mouldcode_code, tm_vendor_code, tm_st_code, tm_qty, tm_itemtext, tm_projecttext, tm_request, tm_owner, tm_category, tm_indate, tm_common, tm_oemasset, tm_rm, tm_createdby, tm_model, tm_group, tm_accountcode, tm_costcentre) values" +
                 *      " ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', '{22}', '{23}', '{24}', '{25}')", chaseno, mouldno, itemcode, rev, status, "Set",
                 *      currency, amount, amounthkd, mpa, mouldcode, vendor, qstatus, quantity, itemtext, projecttext, request, owner, category, DateTime.Today.ToString("yyyy/MM/dd"), common, oemasset, remarks, AdUtil.getUsername("kmhk.local"), model, pgroup, accountcode, costcentre);
                 *  DataService.GetInstance().ExecuteNonQuery(insertText);
                 *
                 *  string updateText = string.Format("update tb_betamould set tm_status = 'Set' where tm_mouldno = '{0}'", mouldno);
                 *  DataService.GetInstance().ExecuteNonQuery(updateText);
                 *
                 * }*/

                string logText = string.Format("insert into tb_log (log_module, log_fromvalue, log_tovalue, log_user, log_datetime, log_chaseno, log_message)" +
                                               " values ('{0}', '{1}', '{2}', N'{3}', '{4}', '{5}', '{6}')", "Quotation", "-", "-", AdUtil.getUsername("kmhk.local"), DateTime.Now.ToString("yyyy/MM/dd"), chaseno, "New Item");

                DataService.GetInstance().ExecuteNonQuery(logText);

                if (transferMode != "From Vendor")
                {
                    string tmchaseno   = chaseno.Replace("MS", "TM");
                    string ownerbefore = cbFromOwner.SelectedItem.ToString();

                    this.saveTransferHistory(mouldno, itemcode, rev, status, ownerbefore, "KDTHK", vendor, vendor, amount, tmchaseno);
                }
            }

            MessageBox.Show("Record has been saved");

            if (formClose != null)
            {
                formClose(this, new EventArgs());
            }
        }