示例#1
0
        private void GetSQLData(SqlCeDataReader getdata)
        {
            dt.Clear();
            array_daily.Clear();
            while (getdata.Read())
            {
                DailyLossQH insert_dl = new DailyLossQH();
                //Object[] array = new Object[6];
                Object[] array = new Object[8];

                insert_dl.itemno   = getdata["ItemNo"].ToString();
                array[0]           = getdata["PostingDate"].ToString();
                insert_dl.location = getdata["Location"].ToString();
                array[1]           = getdata["ItemNo"].ToString();

                insert_dl.quantity = getdata["Quantity"].ToString();
                array[2]           = getdata["Location"].ToString();

                insert_dl.bincode     = getdata["BinCode"].ToString();
                array[3]              = getdata["Quantity"].ToString();
                insert_dl.postingDate = getdata["PostingDate"].ToString();
                array[4]              = getdata["BinCode"].ToString();

                insert_dl.staffdimension = getdata["StaffDimension"].ToString();
                array[5]             = getdata["StaffDimension"].ToString();
                array[6]             = getdata["Lineno"].ToString();
                insert_dl.sqlLineNum = Convert.ToInt16(getdata["Lineno"]);
                array[7]             = getdata["EmptyTank"].ToString();
                insert_dl.emptyTank  = Convert.ToBoolean(getdata["EmptyTank"]);

                //array[5] = getdata["StaffDimension"].ToString();

                array_daily.Add(insert_dl);
                dt.Rows.Add(array);
            }
            lblCount.Text = dt.Rows.Count.ToString();
            CallGridBind();
        }
示例#2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                if (!string.IsNullOrEmpty(txtBinCode.Text.Trim()) && !string.IsNullOrEmpty(txtQuantity.Text.Trim()) && !txtQuantity.Text.Trim().Equals("0") && !string.IsNullOrEmpty(txtItemNo.Text.Trim()) && !string.IsNullOrEmpty(txtQuantity.Text.Trim()) && !string.IsNullOrEmpty(txtLocation.Text.Trim()) && !string.IsNullOrEmpty(txtPostingDate.Text.Trim()))
                //if (!txtBinCode.Text.Equals("") && !txtQuantity.Text.Equals("") && !txtItemNo.Text.Equals("") && !txtQuantity.Text.Equals("") && !txtLocation.Text.Equals("") && !txtPostingDate.Text.Equals(""))
                {
                    bool isNum = IsItNumber(txtQuantity.Text.Trim());

                    if (isNum)
                    {
                        int flagLocation = QtyValidating();

                        //bool flagItem = ItemValidating();

                        if (flagLocation == 1 || flagLocation == 2)
                        {
                            DailyLossQH insert_dl = new DailyLossQH();
                            Object[]    array     = new Object[7];

                            insert_dl.itemno = txtItemNo.Text.Trim();
                            array[0]         = Convert.ToDateTime(txtPostingDate.Text);

                            insert_dl.location       = txtLocation.Text.Trim();
                            array[1]                 = txtItemNo.Text.Trim();
                            insert_dl.quantity       = txtQuantity.Text.Trim();
                            array[2]                 = txtLocation.Text.Trim();
                            insert_dl.bincode        = txtBinCode.Text.Trim();
                            array[3]                 = txtQuantity.Text.Trim();
                            insert_dl.postingDate    = txtPostingDate.Text;
                            array[4]                 = txtBinCode.Text.Trim();
                            insert_dl.staffdimension = staffdim;
                            array[5]                 = staffdim;
                            if (chkEmpty.Checked)
                            {
                                insert_dl.emptyTank = true;
                                array[6]            = true;
                            }
                            else
                            {
                                insert_dl.emptyTank = false;
                                array[6]            = false;
                            }



                            array_daily.Add(insert_dl);
                            dt.Rows.Add(array);
                            lblCount.Text = dt.Rows.Count.ToString();
                            //CallGridBind();

                            CompactSQL comsql = new CompactSQL();
                            comsql.InsertRecord("DailyLoss", array);

                            getdata = comsql.SelectRecord("DailyLoss");
                            GetSQLData(getdata);


                            txtQuantity.Text    = "";
                            txtItemNo.Text      = "";
                            txtLocation.Text    = "";
                            txtPostingDate.Text = "";
                            txtBinCode.Enabled  = true;
                            txtBinCode.Text     = "";
                            txtBinCode.Focus();
                            chkEmpty.Checked = false;
                        }
                        else if (flagLocation == 3)
                        {
                            MessageBox.Show("Item Not found!");
                        }
                        else
                        {
                            //MessageBox.Show("Item Not found!");
                            txtQuantity.Focus();
                            //if (flagLocation == 2)
                            //{
                            //    MessageBox.Show("Item Not found!");
                            //    txtQuantity.Focus();
                            //}
                            //else
                            //{
                            //    MessageBox.Show("Item is not found.");
                            //    txtItemNo.Focus();
                            //}
                        }
                    }
                    else
                    {
                        MessageBox.Show("Quantity value must be integer.");
                        txtQuantity.Text = "";
                        txtQuantity.Focus();
                    }

                    txtQuantity.Enabled    = false;
                    txtPostingDate.Enabled = false;
                    //txtBinCode.Enabled = true;
                }
                else
                {
                    MessageBox.Show("All fields are required to enter and quantity must be larger than 0.");
                    txtBinCode.SelectAll();
                    txtBinCode.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }

            Cursor.Current = Cursors.Default;
        }